package com.ldk.springboot2021.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ldk.springboot2021.mapper.AddressMapper;
import com.ldk.springboot2021.pojo.Address;
import com.ldk.springboot2021.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired(required = false)
    private AddressMapper addressMapper;
    @Override
    public List<Address> findAddressInfoByPage(Integer currentPage, Integer pageSize) {
        //设置分页条件
        PageHelper.startPage(currentPage,pageSize);
        //将需要分页的所有数据查询出来
        QueryWrapper<Address> queryWrapper=new QueryWrapper<>();
        List<Address> list = addressMapper.selectList(queryWrapper);

        PageInfo<Address> pageInfo=new PageInfo<>(list);
        //获取按照分页条件返回的数据
        List<Address> list1= pageInfo.getList();
        return list1;
    }


}
